import {SAVE_CHECKED_KEYS, SAVE_EXPORT_OBJ, SAVE_EXPORT_OBJ_CN, SAVE_SCALE_INDEX} from "./constants";
import {getCurrentDay, getCurrentHours, getCurrentMinutes, getCurrentMonthNumber, getCurrentSeconds, getCurrentYear} from "../../../../common/utils";
import {saveBarchart} from "../../../../components/chart/store/actionCreators";

const defaultState = {
  exportObj: {
    hasLogo: true,
    hasHeader: true,
    header: {
      headerAlign: "center",
      hasTitle: true,
      title: `${getCurrentYear()}-${(getCurrentMonthNumber() + "").padStart(2, "0")}-${getCurrentDay()}-${getCurrentHours()}-${getCurrentMinutes()}-${getCurrentSeconds()}`,  //  TODO
      hasSubTitle: true,
      subTitle: `${getCurrentYear()}/${getCurrentMonthNumber()}/${getCurrentDay()} ${getCurrentHours()}:${getCurrentMinutes()}`,//  TODO
      // hasLogo: true,
      imgLogo: "" //  TODO
    },
    hasExperiment: true,
    experiment: {
      hasInformation: true,
      information: {
        name: "",
        barcode: "",
        userName: "",
        instrumentName: "",
        blockType: ""
      },
      hasExperimentSetting: true,
      experimentSetting: {
        experimentIdentify: "Quantitation/Standard Curve",  //  TODO:改名字
        reagentsType: "Probe",  //  TODO:改名字
        runMode: "Standard/Sample Temperature"
      },
      hasParameterSetting: true,
      parameterSetting: {
        reactionVolume: "",
        lidHeatingSwitch: "YES",
        coverTemp: "",
        lidCloseTemp: ""
      },
      hasComments: true,
      comments: "",
      hasLoadPreview: false,
      imgLoadPreviewPlate: "",
      imgLoadPreviewProtocol: ""
    },
    hasPlate: true,
    plate: {
      hasPlateLayout: true,
      plateLayout: [],
      hasTask: true,
      task: "Unk: 0个\nNtc: 0个\nPos: 0个\nNeg: 0个\nNrt: 0个\nStd: 0个\nEmpty: 96个",
      hasTarget: true,
      target: [],
      hasSplitPlate: true,
      splitPlate: "", //  TODO
      hasSample: false,
      sample: [],
      hasStandard: true,
      standard: {
        selectTarget: "",
        standardAmount: "",
        standardNumber: "",
        factor: "",
        dilutionFactor: "",
        unit: "",
        replicates: "",
        increasing_decreasing: "",
        assignment: 0
      }
    },
    hasProtocol: true,
    protocol: {
      hasProtocol: true,
      protocol: "",
      advancedSetting: "",  //  TODO
      imgProtocolGraph: ""
    },
    hasRun: true,
    run: {
      hasRunTime: true,
      runTime: "",
      hasTemperatureCurve: true,
      imgTemperatureCurve: ""
    },
    hasAnalysis: true,
    analysis: {
      hasQuantification: true,
      imgAmplificationCurve_cq: "",
      imgAmplificationCurve_log: "",
      hasStandardCurve: true,
      imgStandardCurve: "",
      standardCurveFormulas: [],  //TODO
      hasQuantificationData: true,
      quantificationData: [], //TODO
      hasMelt: true,
      imgMeltCurve: "",
      imgMeltPeak: "",
      hasMeltData: true,
      meltData: [], //TODO
      hasGeneExpression: true,
      imgGeneExpressionBar: "",  //TODO
      geneExpressionMode: "", //TODO
      geneExpressionData: [],  //TODO
      hasAllelic: true,
      imgAllelic_cq: "",
      imgAllelic_rfu: "",
      allelicData: [],
      hasQuanlityControl: true,
      failureReportData: [],
      quanlityControlSettingData: [],
      hasEndPoint: true,
      endPointData: [],
      endPointSettingData: []
    },
    type: "docx",
    language: "English"
  },
  exportObjCn: {
    hasLogo: true,
    hasHeader: true,
    header: {
      headerAlign: "居中",
      hasTitle: true,
      title: `${getCurrentYear()}-${(getCurrentMonthNumber() + "").padStart(2, "0")}-${getCurrentDay()}-${getCurrentHours()}-${getCurrentMinutes()}-${getCurrentSeconds()}`,  //  TODO
      hasSubTitle: true,
      subTitle: `${getCurrentYear()}/${getCurrentMonthNumber()}/${getCurrentDay()} ${getCurrentHours()}:${getCurrentMinutes()}`,//  TODO
      // hasLogo: true,
      imgLogo: "" //  TODO
    },
    hasExperiment: true,
    experiment: {
      hasInformation: true,
      information: {
        name: "",
        barcode: "",
        userName: "",
        instrumentName: "",
        blockType: ""
      },
      hasExperimentSetting: true,
      experimentSetting: {
        experimentIdentify: "绝对定量/标准曲线",  //  TODO:改名字
        reagentsType: "探针法",  //  TODO:改名字
        runMode: "标准/试管控温"
      },
      hasParameterSetting: true,
      parameterSetting: {
        reactionVolume: "",
        lidHeatingSwitch: "是",
        coverTemp: "",
        lidCloseTemp: ""
      },
      hasComments: true,
      comments: "",
      hasLoadPreview: false,
      imgLoadPreviewPlate: "",
      imgLoadPreviewProtocol: ""
    },
    hasPlate: true,
    plate: {
      hasPlateLayout: true,
      plateLayout: [],
      hasTask: true,
      task: "Unk: 0个\nNtc: 0个\nPos: 0个\nNeg: 0个\nNrt: 0个\nStd: 0个\nEmpty: 96个",
      hasTarget: true,
      target: [],
      hasSplitPlate: true,
      splitPlate: "", //  TODO
      hasSample: false,
      sample: [],
      hasStandard: true,
      standard: {
        selectTarget: "",
        standardAmount: "",
        standardNumber: "",
        factor: "",
        dilutionFactor: "",
        unit: "",
        replicates: "",
        increasing_decreasing: "",
        assignment: 0
      }
    },
    hasProtocol: true,
    protocol: {
      hasProtocol: true,
      protocol: "",
      advancedSetting: "",  //  TODO
      imgProtocolGraph: ""
    },
    hasRun: true,
    run: {
      hasRunTime: true,
      runTime: "",
      hasTemperatureCurve: true,
      imgTemperatureCurve: ""
    },
    hasAnalysis: true,
    analysis: {
      hasQuantification: true,
      imgAmplificationCurve_cq: "",
      imgAmplificationCurve_log: "",
      hasStandardCurve: true,
      imgStandardCurve: "",
      standardCurveFormulas: [],  //TODO
      hasQuantificationData: true,
      quantificationData: [], //TODO
      hasMelt: true,
      imgMeltCurve: "",
      imgMeltPeak: "",
      hasMeltData: true,
      meltData: [], //TODO
      hasGeneExpression: true,
      imgGeneExpressionBar: "",  //TODO
      geneExpressionMode: "", //TODO
      geneExpressionData: [],  //TODO
      hasAllelic: true,
      imgAllelic_cq: "",
      imgAllelic_rfu: "",
      allelicData: [],
      hasQuanlityControl: true,
      failureReportData: [],
      quanlityControlSettingData: [],
      hasEndPoint: true,
      endPointData: [],
      endPointSettingData: []
    },
    type: "docx",
    language: "Chinese"
  },
  reduxCheckedKeys: [/*"0-hasLogo",*/ "1-hasHeader", "2-hasTitle", "3-hasSubTitle", /*"4-hasLogo",*/ "5-hasExperiment", "6-hasInformation", "7-hasExperimentSetting", "8-hasParameterSetting",
    "9-hasComments",
    "11-hasPlate", "12-hasPlateLayout", "13-hasTask", "14-hasTarget", "15-hasSplitPlate", "16-hasSample", "17-hasStandard", "18-hasProtocol", "19-hasProtocol", "20-hasRun",
    "21-hasRunTime", "22-hasTemperatureCurve", "23-hasAnalysis", "24-hasQuantification", "25-hasStandardCurve", "26-hasQuantificationData", "27-hasMelt", "28-hasMeltData",
    "29-hasGeneExpression", "30-hasAllelic", "31-hasQuanlityControl", "32-hasEndPoint"],
  scaleIndex: 5,
};

export default function reducer(state = defaultState, action) {
  switch (action.type) {
    case SAVE_EXPORT_OBJ :
      return {...state, exportObj: action.exportObj};
      case SAVE_EXPORT_OBJ_CN :
      return {...state, exportObjCn: action.exportObjCn};
    case SAVE_CHECKED_KEYS :
      return {...state, reduxCheckedKeys: action.reduxCheckedKeys};
    case SAVE_SCALE_INDEX :
      return {...state, scaleIndex: action.scaleIndex};
    default:
      return state;
  }
}